package com.example.demo.service.dataSource2;

import com.example.demo.dao.dataSource2.ESDictMapper;
import com.example.demo.entity.dataSource2.ESDictEntity;
import com.example.demo.service.dataSource2.ESDictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by Wen Gao on 2018/7/11.
 */
@Service
@Transactional(transactionManager = "xatx", propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
public class ESDictService {

    @Autowired
    private ESDictMapper esDictMapper;

    /**
     * @return 成功插入的记录数
     * */
    public int insert(ESDictEntity entity) {
        return esDictMapper._insert(entity);
    }

    public void update(ESDictEntity entity) {
        esDictMapper.update(entity);
    }

    public List<String> getAllWords() {
        return esDictMapper.selectAllWords();
    }

    public List<ESDictEntity> getByWord(String word) {
        return esDictMapper.selectByWord(word);
    }
}
